package com.szrt.javaweb.demo;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class JsonController {
	/*
	 * 如何把 UserEntity类的对象entity转化成json格式的字符串
	 * 答：只需要增加1个注解 @ResponseBody {"usename":"Scott","age":"33"}
	 * {"username":"Scott","age":33}
	 * http://localhost:8080/mvn-springmvc-01-1609/findById?username=zxx&age=33
	 */
	@RequestMapping("/findById")
	@ResponseBody
	public UserEntity findById(){
		UserEntity entity  = new UserEntity();
		entity.setUsername("Scott");
		entity.setAge(33);
		return entity;
	}
	
	
	/*@RequestMapping("/findById")
	@ResponseBody
	public Map<String,String> findByIdMap(){
		
		return null;
	}
	
	
	@RequestMapping("/findById")
	@ResponseBody
	public List<Map<String,String>> findByIdList(){
		
		return null;
	}*/
	
	
	
	
	
	

}
